package com.example.yrdev.ordering_system.Database;

import android.content.Context;

import com.example.yrdev.ordering_system.Model.PurchaseReport;
import com.example.yrdev.ordering_system.Utils.GlobalFunction;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * Created by luke on 10/11/16.
 */

public class RefundGoodTB {

    public static   final String DH_TABLE_NAME = "refund_item";

    public static   final String  item_CardID="item_CardID";
    public static   final String  item_TicketID="item_TicketID";
    public static   final String  item_ID="item_ID";//商品编号
    public static   final String  item_name="item_Name";//商品名称
    public static  final String  item_PurchaseVolume="item_PurchaseVolume";//数量

    public static  final String  item__amount="item__amount";//数量
    public static  final String  item_totalPrice="item_totalPrice";
    public static  final String  item_purchDate="item_purchDate";
    public static  final String  item_refundDate="item_refundDate";
    public static  final String item_restoredNum="item_restoredNum";


    public static final String item_httpDateTimeCopy="item_httpDateTimeCopy";

    public static  final String  item_payMode="item_payMode";//0 现金,1 信用卡,2 签单,3 会员卡,4 礼劵, 8 - 退货  会员卡,9 - 退货  现金
    public static  final String item_Discount="item_Discount";
    public static  final String item_PrimeCost="item_primeCost";//进货价
    public  static final String item_SaleCost="item_saleCost";//会员价
    public static  final String item_EmployeID="EmployeeID";

    public static  final String item_uploadMark="item_uploadMark";
    public  static final String DH_CREATE_TABLE="CREATE TABLE " + DH_TABLE_NAME + "( " +item_CardID+ " TEXT," + item_TicketID + " TEXT," + item_ID + " TEXT," + item_name + " TEXT, "
            + item__amount + " INTEGER," + item_PurchaseVolume+" INTEGER,"+ item_restoredNum +" INTEGER,"+ item_totalPrice + " INTEGER," + item_purchDate + " TEXT," +item_refundDate+" TEXT,"
            + item_payMode + " INTEGER, " + item_Discount +" TEXT," + item_httpDateTimeCopy+ " TEXT,"
            + item_PrimeCost+" TEXT,"+ item_SaleCost + " TEXT ,"+item_uploadMark+" INTEGER,"+item_EmployeID+" TEXT"+ ")";




    public static void insertRecord(Context context,RefundGoodTB.Item item){

        DingHanDB.getInstance(context).insert(DH_TABLE_NAME,item);

    }
    public static void changeRefundReportUploadMark(Context context,RefundGoodTB.Item record){
        record.setUploadMark(1);
        DingHanDB.getInstance(context).changeRefundReportUploadMark(record);
    }
    public static ArrayList<RefundGoodTB.Item> getRefundItemList(Context context, PurchaseReport item){//查询有没有相应的货，曾经退过

     return DingHanDB.getInstance(context).getRefundedItemList(item);

    }
    public static ArrayList<Item>getAllRefundItemBaseOnType(Context context,int type){
        return DingHanDB.getInstance(context).getAllRefundedItemListBaseOnType(type);
    }


    public static class Item implements Serializable {
        String card_ID = "0";
        String item_ID = "item_ID";//商品编号
        String item_TicketID = "";//发票号
        String item_name;//商品名称
        Integer item_amount;//数量
        Integer purchaseVolume;

        Integer item_totalPrice;
        String item_purchDate;
        String item_refundDate;
        Integer item_payMode = 0;//0 现金,1 信用卡,2 签单,3 会员卡,4 礼劵, 8 - 退货  会员卡,9 - 退货  现金
      String  discountRate;

         String primeCost;//进货价
        Double saleCost;//会员价
        String employeeID = "";
        String payModeText = "现金";
        Integer totalPrice;
        Integer uploadMark;
        Integer restoredNum;
        String  httpDateTime;


        public Item(String item_ID) {

            this.item_ID = item_ID;

        }

        public void setPurchaseVolume(Integer purchaseVolume) {
            this.purchaseVolume = purchaseVolume;
        }

        public void setRestoredNum(Integer restoredNum) {
            this.restoredNum = restoredNum;
        }

        public void setCard_ID(String card_ID) {
            this.card_ID = card_ID;
        }

        public String getCard_ID() {
            return card_ID;
        }


        public void setItem_ID(String item_ID) {
            this.item_ID = item_ID;

        }

        public String getItem_ID() {
            return item_ID;

        }

        public void setItem_TicketID(String item_TicketID) {
            this.item_TicketID = item_TicketID;
        }

        public void setItem_name(String item_name) {
            this.item_name = item_name;
        }

        public String getItem_name() {
            return item_name;
        }

        public Integer getItem_amount() {
            return item_amount;
        }

        public Double getSaleCost() {
            return saleCost;
        }

        public void setDiscountRate(String discountRate) {
            this.discountRate = discountRate;
        }

        public void setItem_amount(Integer item_amount) {
            this.item_amount = item_amount;
        }

        public void setSaleCost(Double saleCost) {
            this.saleCost = saleCost;
        }

        public void setPrimeCost(String primeCost) {
            this.primeCost = primeCost;
        }

        public void setHttpDateTime(String httpDateTime) {
            this.httpDateTime = httpDateTime;
        }

        public void setItem_payMode(Integer item_payMode) {
            this.item_payMode = item_payMode;
        }

        public void setUploadMark(Integer uploadMark) {
            this.uploadMark = uploadMark;
        }

        public Integer getItem_payMode() {
            return item_payMode;
        }

        public Integer getPurchaseVolume() {
            return purchaseVolume;
        }

        public void setItem_purchDate(String item_purchDate) {
            this.item_purchDate = item_purchDate;
        }

        public String getItem_TicketID() {
            return item_TicketID;
        }

        public String getPayModeText() {
            switch (item_payMode) {
                case 3:
                    payModeText = "刷卡";

            }
            return payModeText;
        }

        public Double getTotalPrice() {

            return item_amount * saleCost;

        }

        public String getDiscountRate() {
            return discountRate;
        }


        public String getItem_purchDate() {
            return item_purchDate;
        }

        public String getItem_refundDate() {
            if (item_refundDate==null||item_refundDate==""){
                item_refundDate=GlobalFunction.getCurrentDateTime();

            }

           return item_refundDate;

        }

        public String getHttpDateTime() {
            return httpDateTime;
        }


        public Integer getRestoredNum() {
            return restoredNum;
        }

        public String getPrimeCost() {
            return primeCost;
        }

        public void setEmployeeID(String employeeID) {
            this.employeeID = employeeID;
        }

        public String getEmployeeID() {
            return employeeID;
        }

        public Integer getUploadMark() {
            return uploadMark;
        }
    }


}
